import 'package:flutter/material.dart';
import './data.dart';

void main() {
  runApp(MaterialApp(
    home: Scaffold(
      appBar: AppBar(title: const Text('这是列表页面')),
      body: const MyText(),
    ),
  ));
}

// List<Widget> renderList() {
//   List<Widget> domList = [];

//   for (var i in listData) {
//     domList.add(ListTile(
//       leading: Image.network(i["avator"]),
//       title: Text(i["content"]),
//       subtitle: Text(i["name"]),
//     ));
//   }
//   return domList;
// }

// 动态添加列表
class MyText extends StatelessWidget {
  const MyText({super.key});

  @override
  Widget build(BuildContext context) {
    return ListView.builder(
      itemCount: listData.length,
      itemBuilder: (context, index) {
        return ListTile(
          leading: Image.network(listData[index]["avator"]),
          title: Text('${listData[index]['content']}'),
          subtitle: Text(listData[index]["name"]),
        );
      },
    );
  }
}
